// 推荐相关 API

import request from './index';
import type { ApiResponse, GetRecommendationsResponse } from '@/types/api';
import { mockGetRecommendations, mockRecommendationFeedback } from '@/mock/recommendation';

const useMock = import.meta.env.VITE_USE_MOCK === 'true';

/**
 * 获取推荐列表
 */
export const getRecommendations = async (): Promise<ApiResponse<GetRecommendationsResponse>> => {
  if (useMock) {
    return mockGetRecommendations();
  }
  return request.get('/recommendations');
};

/**
 * 推荐反馈
 */
export const recommendationFeedback = async (
  recommendationId: string, 
  helpful: boolean
): Promise<ApiResponse<null>> => {
  if (useMock) {
    return mockRecommendationFeedback(recommendationId, helpful);
  }
  return request.post('/recommendations/feedback', { recommendationId, helpful });
};